When cancelling an in-progress request, allow specifying the error returned to clients#33
Open
ahoppen wants to merge 1 commit intoswiftlang:mainfrom
Open
When cancelling an in-progress request, allow specifying the error returned to clients#33ahoppen wants to merge 1 commit intoswiftlang:mainfrom
ahoppen wants to merge 1 commit intoswiftlang:mainfrom
Conversation
…turned to clients Currently, when implicitly cancelling requests because a document has been changed, we return an error response that indicates that the client cancelled the request because we translated all `CancellationError` to this response. The more accurate response is to indicate that the content has been modified, returning a `ContentModified` error. To do so, we need to make two changes: - `QueueBasedMessageHandler` needs to keep track of the reasons why it cancelled request handling tasks - The protocol requirement `QueueBasedMessageHandler.handle(request:id:reply)` needs to allow returning `CancellationError` instead of eagerly transforming it to a `ResponseError` in `RequestAndReply`. This is an API-breaking change. I haven’t found a great way to add a compatibility layer, so I propose that we need to have linked PRs in SourceKit-LSP and SwiftPM that need to be merged when we are updating the swift-tools-protocols version in the toolchain.
ahoppen
added a commit
to ahoppen/sourcekit-lsp
that referenced
this pull request
Jan 4, 2026
… of `ResponseError` Update for the API changed in swiftlang/swift-tools-protocols#33.
ahoppen
added a commit
to ahoppen/swift-package-manager
that referenced
this pull request
Jan 4, 2026
… of `ResponseError` Update for the API changed in swiftlang/swift-tools-protocols#33.
ahoppen
added a commit
to ahoppen/swift-build
that referenced
this pull request
Jan 4, 2026
… of `ResponseError` Update for the API changed in swiftlang/swift-tools-protocols#33.
owenv
approved these changes
Jan 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, when implicitly cancelling requests because a document has been changed, we return an error response that indicates that the client cancelled the request because we translated all
CancellationErrorto this response. The more accurate response is to indicate that the content has been modified, returning aContentModifiederror.To do so, we need to make two changes:
QueueBasedMessageHandlerneeds to keep track of the reasons why it cancelled request handling tasksQueueBasedMessageHandler.handle(request:id:reply)needs to allow returningCancellationErrorinstead of eagerly transforming it to aResponseErrorinRequestAndReply. This is an API-breaking change. I haven’t found a great way to add a compatibility layer, so I propose that we need to have linked PRs in SourceKit-LSP and SwiftPM that need to be merged when we are updating the swift-tools-protocols version in the toolchain.This is a prerequisite to fixing swiftlang/sourcekit-lsp#2136 (comment).
PRs that need to be merged when this gets picked up in toolchain builds:
QueueBasedMessageHandler.handleto returnany Errorinstead ofResponseErrorsourcekit-lsp#2416QueueBasedMessageHandler.handleto returnany Errorinstead ofResponseErrorswift-package-manager#9557QueueBasedMessageHandler.handleto returnany Errorinstead ofResponseErrorswift-build#1003